@extends("admin.layouts.main")
<style>
	.my-ver-align{vertical-align: -2px;}
	.btn-link{color:gray;}
	.my-daili{
		top:50%;
		right:0;
		z-index:1;
		margin-top:-13.6px;
	}
</style>
@section("content")
	<div class="container-fiuld p-3">
		<div class="card">
			<div class="card-body pt-1">
				<div class="row mt-1 mb-2">
					<div class="col-lg-12 pt-3 pb-3" style="background-color:#F2F2F2">
						<form class="form-inline position-relative">
							<label for="created_at">时间：</label>
							<input type="text" name="stime" class="layui-input test-laydate-item form-control mr-3" style="border-color:#ced4da" id="stime" value="{{$stime}}" placeholder="开始时间" lay-key="1">
							<input type="text" name="etime" class="layui-input test-laydate-item form-control mr-3" style="border-color:#ced4da" id="etime" value="{{$etime}}" placeholder="结束时间" lay-key="2">
							<a class="btn btn-primary btn-sm ml-5 mr-3 search text-white">查询</a>
							<button type="reset" class="btn btn-secondary mr-3 btn-sm">重置</button>
						</form>
					</div>
				</div>
			<div class="row">
				<div class="col-lg-12 table-responsive">
					<table class="table layui-form">
						<thead class="thead-light">
							<tr class="text-dark">
							<!--<th><input type="checkbox"></th>-->
								<th>姓名</th>
								<th>支付宝</th>
								<th>佣金</th>
								<th>第三方订单号</th>
								<th>时间</th>
								<th>状态</th>
							</tr>
						</thead>
						<tbody>
							@foreach($agent as $v)
							<tr>
								<td>{{ $v->drawals->name}}</td>
								<td>{{ $v->drawals->alipay}}</td>
								<td>{{ $v->money}}</td>
								<td>{{ $v->order_id}}</td>
								<td>{{ date('Y-m-d', strtotime($v->created_at)) }}</td>
								<td>@if($v->status == 0) {{"审核中"}} @elseif($v->status == 1){{"提现成功"}}@else{{"提现失败"}} @endif</td>

							</tr>
							@endforeach
						</tbody>
					</table>
				</div>
			</div>
		</div>
		<div style="text-align: right;">
			{{ $agent->appends(['stime'=>$stime, 'etime' => $etime])->links('admin.layouts.paginate') }}
		</div>
    </div>
</div>
@endsection

@section("js")
	<script type="text/javascript">
        layui.use(['form', 'ori',"laydate"], function () {
            var form = layui.form,
                ori = layui.ori,
                dialog = layui.dialog,
                $ = layui.$
            laydate = layui.laydate;
            var	stime = '';
            var	etime = '';
            lay('.test-laydate-item').each(function(){
                laydate.render({
                    elem: this
                    ,trigger: 'click'
                });
            });

            $('.search').click(function () {
                var stime = $("#stime").val();
                var etime = $("#etime").val();
                location.href = "{{ route('withdrawalList') }}" + '?stime=' + stime + ' &etime='+ etime;
            });

            form.on('switch(active)',function (data) {
                var isActive = data.elem.checked, val, _that = $(this);
                val = (isActive === true) ? 1 : 0;
                ori.submit(_that, {field: 'status', val: val}, '', function () {
                    _that.prop('checked', !isActive);
                    form.render('checkbox');
                })
                return false;
            });
        });
	</script>
@endsection
